package com.security.config.mobile;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class MobileCode {

    private String code;

    private LocalDateTime expireTime;

    private String mobile;


    public MobileCode(String code, String mobile, int expireAfterSeconds){
        this.code = code;
        this.mobile = mobile;
        this.expireTime = LocalDateTime.now().plusSeconds(expireAfterSeconds);
    }

    public boolean isExpired(){
        return LocalDateTime.now().isAfter(expireTime);
    }

}
